#!/bin/bash

if [ `uname` == "Darwin" ] ; then
    echo "-- warn, $0 only can execute on linux."
    exit 0 
fi

#get this script real directory
SOURCE="$0"
while [ -h "$SOURCE"  ]; do # resolve $SOURCE until the file is no longer a symlink
    this_script_dir="$( cd -P "$( dirname "$SOURCE"  )" && pwd  )"
    SOURCE="$(readlink "$SOURCE")"
    # if $SOURCE was a relative symlink, 
    #we need to resolve it relative to the path 
    #where the symlink file was located
    [[ $SOURCE != /*  ]] && SOURCE="$this_script_dir/$SOURCE"
done
this_script_dir="$( cd -P "$( dirname "$SOURCE"  )" && pwd  )"

p2pcpp_src=$this_script_dir/../../

cd $p2pcpp_src/build && pwd &&cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/run -DLINK_STATIC=ON && make install

cd $HOME/git/release/p2pcpp_release/ && git pull

if [ -f $HOME/run/log/*.log ] ; then
    rm $HOME/run/log/*.log
fi

cp -rp $HOME/run/* $HOME/git/release/p2pcpp_release/natpunch/

echo "-- info, git push dir:$HOME/git/release/p2pcpp_release"
cd $HOME/git/release/p2pcpp_release
git add . && git commit -m'add by $0' && git push
echo "-- info, git push dir:$HOME/git/release/p2pcpp_release"






